<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" />
<script src="webjars/jquery/jquery.min.js"></script>
<script src="webjars/bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/webjars/bootstrap/css/bootstrap.min.css" />
<script type="text/javascript">
	$(document).ready(function() {
		//登录
		$('#login').click(function() {
			
			var username = $('#username').val();
			var password1 = $('#password1').val();
			var password2 = $('#password2').val();
			var checkbox = $('#checkbox').is(':checked');
			if (username == "") {
				alert('用户名不能为空');
				return;
			}
			if (password1 == "" || password2 == "") {
				alert('密码不能为空');
				return;
			}
			if (!checkbox) {
				alert('请先验证你是不是人类');
				return;
			}
			/* if (password1 != password2) {
				alert('密码不一致');
				return;
			} */
			
			$.post("/modifyPassword", {
				username : username,
				password1 : password1,
				password2 : password2,
			}, function(data, status) {
				if (data.status == "success") {
					$(location).attr("href", "/home?username=" + username);
				} else {
					alert('【' + data.summary + '】' + data.description);
				}
			});
			
		});

	});
</script>
</head>
<body>
	<div class="container">
		<h1>
			<center>Web开发学习平台</center>
		</h1>
	</div>
	<div>
			<div class="form-group">
				<label for="username" class="col-sm-2 control-label">用户名</label>
				<div class="col-sm-2">
					<input type="text" class="form-control" id="username"
						name="username" placeholder="请输入用户名" />
				</div>
			</div>
			<div class="form-group">
				<label for="password" class="col-sm-2 control-label">新密码</label>
				<div class="col-sm-2">
					<input type="password" class="form-control" id="password1"
						name="username" placeholder="请输入新密码" />
				</div>
			</div>
			<div class="form-group">
				<label for="password" class="col-sm-2 control-label">重复密码</label>
				<div class="col-sm-2">
					<input type="password" class="form-control" id="password2"
						name="password" placeholder="请再次输入密码" />
				</div>
			</div>
			<div class="form-group">
			<div class="col-sm-offset-2 col-sm-10">
				<label> <input id="checkbox" type="checkbox" /> 我是人类</label>
			</div>
		</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" id="login" class="btn btn-info">修改密码</button>
				</div>
			</div>
	</div>
</body>
</html>